<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>信息提交</title>
    <link href="/assets/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f8f9fa;
            padding: 20px;
        }
        .form-container {
            max-width: 500px;
            margin: 0 auto;
            background: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        .form-container h1 {
            text-align: center;
            margin-bottom: 20px;
            font-size: 24px;
            color: #333;
        }
        .form-group label {
            font-weight: bold;
            color: #555;
        }
        .form-control {
            border-radius: 4px;
            border: 1px solid #ddd;
            padding: 10px;
        }
        .btn-primary {
            width: 100%;
            padding: 10px;
            font-size: 16px;
            border-radius: 4px;
            background-color: #007bff;
            border: none;
        }
        .btn-primary:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
<div class="form-container">
    <h1>信息提交</h1>
    <form id="userInfoForm">
        <!-- 工号 -->
        <div class="form-group mb-3">
            <label for="job_number">工号：</label>
            <input type="text" class="form-control" id="job_number" name="job_number" placeholder="请输入工号" required>
        </div>

        <!-- 物品 -->
        <div class="form-group mb-3">
            <label for="item">物品：</label>
            <input type="text" class="form-control" id="item" name="item" placeholder="请输入物品名称" required>
        </div>

        <!-- 姓名 -->
        <div class="form-group mb-3">
            <label for="name">姓名：</label>
            <input type="text" class="form-control" id="name" name="name" placeholder="请输入姓名" required>
        </div>

        <!-- 电话 -->
        <div class="form-group mb-3">
            <label for="phone">电话：</label>
            <input type="tel" class="form-control" id="phone" name="phone" placeholder="请输入电话" required>
        </div>
        <!-- 电话 -->
        <div class="form-group mb-3">
            <label for="phone">地址：</label>
            <input type="text" class="form-control" id="address" name="address" placeholder="请输入地址" required>
        </div>

        <!-- 提交按钮 -->
        <button type="submit" class="btn btn-primary">提交</button>
    </form>
    <div id="resultMessage" class="mt-3"></div>
</div>

<!-- 引入 jQuery -->
<script src="/assets/jquery.min.js"></script>
<script>
    $(document).ready(function () {
        // 表单提交事件
        $('#userInfoForm').on('submit', function (e) {
            e.preventDefault(); // 阻止默认表单提交

            // 显示加载状态
            $('#resultMessage').html('<div class="alert alert-info">提交中，请稍候...</div>');

            // 获取表单数据
            var formData = $(this).serialize();

            // 发送 AJAX 请求
            $.ajax({
                url: 'https://from1.bigchun.com/api/index/submit', // 提交地址
                type: 'POST',
                data: formData,
                success: function (response) {
                    if (response.code === 1) {
                        // 提交成功
                        $('#resultMessage').html('<div class="alert alert-success">' + response.msg + '</div>');
                        $('#userInfoForm')[0].reset(); // 清空表单
                    } else {
                        // 提交失败
                        $('#resultMessage').html('<div class="alert alert-danger">' + response.msg + '</div>');
                    }
                },
                error: function () {
                    // 请求失败
                    $('#resultMessage').html('<div class="alert alert-danger">请求失败，请稍后重试</div>');
                }
            });
        });
    });
</script>
</body>
</html>